#include <stdio.h>
#include <error.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <limits.h>
#include <poll.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/epoll.h>
#include <time.h>
#include <list>
#include <arpa/inet.h>
#include <assert.h>

#define SERVER_PORT         8888                    //监听端口
#define SERVER_HOST         "172.18.182.97"         //服务器IP地址


int main(int argc, char *argv[])
{

    char *content = argv[1];

    printf("send:%s\n",content);

    int sockfd;
    struct sockaddr_in addr;

    addr.sin_family = AF_INET;
    addr.sin_port = htons(SERVER_PORT);
    addr.sin_addr.s_addr = inet_addr(SERVER_HOST);

    sockfd = socket(PF_INET, SOCK_STREAM, 0);
    assert(sockfd >= 0);

    int ret = connect(sockfd, (struct sockaddr *)&addr, sizeof(addr));
    assert(ret != -1);

    char *buff;
    int buff_len = 16;
 
    send(sockfd, content, sizeof(content),0);

    printf("%s:%d\n","sockfd", sockfd);
    int len = recv(sockfd, buff, buff_len, 0);
    if(len > 0)
    {
        printf("%s:%d\n",buff, len);
    }

    close(sockfd);

}